Web APIs are used to exchange data via the internet, and typically have the following characteristics:
resources are accessed via URLs with the structure:
{base_url}{endpoint}
support data transfer using standard HTTP methods:
GET, POST, PUT, and DELETE
data is transferred in the following formats:
JSON(most common and what we'll focus on), XML or YAML
https://api.spotify.com/v1 is the base URL for the main Spotify API, onto which numerous endpoints can be added, such as:
/browse/categories
/artists/albums
/tracks/{id}
URI used instead (Uniform Resource Identifier)GET and POST requests¶Our focus will be on GET and POST methods (also known as requests), which are the methods typcially needed to access data from a web API.
GET: used to request data from the given resource
POST: used to send data to create or update a resource
GET requests¶GET requests can contain a query string of key=value pairs in the URL to request more specific data
https://api.spotify.com/v1/browse/new-releases?country=SE&limit=10? and key=value pairs, each separated by &POST requests¶POST requests can send data within the request body